/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.treeeditpart;

import java.beans.PropertyChangeListener;

import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.uml2.uml.Property;

import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.listener.UmlElementListener;

/**
 * 
 * 
 * @author Patrick Tessier
 * 21 juin 06
 */


public class PropertyTreeEditPart extends ElementTreeEditPart
implements PropertyChangeListener{//,IResource {

	
	/**
 * 
 */
private int channel =20;
	
	/**
	 * Create a new instance of this edit part using the given model element.
	 * 
	 * @param modelManager 
	 * @param model a non-null
	 */
	public PropertyTreeEditPart(org.eclipse.uml2.uml.Property model,ModelManager modelManager) {
		super(model,modelManager);
		 _adapter = new UmlElementListener(this);		 
	}

    /*
     * (non-Javadoc)
     * @see com.cea.papyrus.Newtree.ElementTreeEditPart#getModelChildren()
     */
    //@Override
	/*protected List getModelChildren() {
    	return new ArrayList();
    }*/


    /**
     * 
     */
    @Override
	public void activate() {
		if (!isActive()) {
			super.activate();
			
			if( ((Property)getUmlElement()).getAssociation()!= null){
				((Notifier)((Property)getUmlElement()).getAssociation()).eAdapters().add(_adapter);
			}
			if( ((Property)getUmlElement()).getUpperValue()!= null){
				((Notifier)((Property)getUmlElement()).getUpperValue()).eAdapters().add(_adapter);
			}
			if( ((Property)getUmlElement()).getLowerValue()!= null){
				((Notifier)((Property)getUmlElement()).getLowerValue()).eAdapters().add(_adapter);
			}
			if( ((Property)getUmlElement()).getType()!= null){
				((Notifier)((Property)getUmlElement()).getType()).eAdapters().add(_adapter);
			}
			
		}
	}

    /**
     * 
     */
    @Override
	public void deactivate() {
		if (isActive()) {
			super.deactivate();

			
			if( ((Property)getUmlElement()).getAssociation()!= null){
				((Notifier)((Property)getUmlElement()).getAssociation()).eAdapters().remove(_adapter);
			}
			if( ((Property)getUmlElement()).getUpperValue()!= null){
				((Notifier)((Property)getUmlElement()).getUpperValue()).eAdapters().remove(_adapter);
			}
			if( ((Property)getUmlElement()).getLowerValue()!= null){
				((Notifier)((Property)getUmlElement()).getLowerValue()).eAdapters().remove(_adapter);
			}
			if( ((Property)getUmlElement()).getType()!= null){
				((Notifier)((Property)getUmlElement()).getType()).eAdapters().remove(_adapter);
			}
		}
	}
	

}